
using Crux.Core.Domains;

namespace Crux.Core.NHibernate;
/// <inheritdoc/>
public class ServiceProviderInterceptor(IServiceProvider? provider) : EmptyInterceptor
{
    /// <inheritdoc/>
    public override bool OnLoad(
        object instance,
        object id,
        object[] state,
        string[] propertyNames,
        IType[] types)
    {
        if (instance is IInjectServiceProvider entity)
        {
            entity.ServiceProvider = provider;
        }

        return base.OnLoad(instance, id, state, propertyNames, types);
    }
}